import axios from "./request";
import { IErrorData, ISuccessPageData } from "./returnData";

export interface ISettingObj {
    avatar: string,
    siteTitle: string,
    github: string,
    qq: string,
    qqQrCode: string,
    weixin: string,
    weixinQrCode: string,
    mail: string,
    icp: string,
    githubName: string,
    favicon: string,
    id: string
}

/**
 * 获取全局设置
 * @returns 
 */
export function getSetting(): Promise<ISuccessPageData<ISettingObj> | IErrorData> {
    return axios.get('/api/setting')
}

//修改数据内容
export function updateSetting(setting: Partial<ISettingObj>): Promise<ISuccessPageData<ISettingObj> | IErrorData> {
    return axios.put('/api/setting', setting)
}